package cn.denny.designpattern.iterator;



public class IteratorImpl<T> extends AbstractIterator{

	private List<T> list ;
	private int currentIndex = 0;
	public IteratorImpl(List<T> list){
		this.list = list;
	}
	
	@Override
	public void first() {
		currentIndex = 0;
	}

	@Override
	public int size() {
		if(list == null){
			return 0;
		}
		return list.getSize();
	}

	@Override
	public T next() {
		if(hasNext()){
			return list.get(currentIndex++);
		}
		return null;
	}

	@Override
	public boolean hasNext() {
		if(currentIndex < list.getSize()){
			return true;
		}
		return false;
		
	}

}
